package com.sun.common.core.excel.model;


import java.io.Serializable;
import java.util.Objects;
import java.util.StringJoiner;

/**
 * The type Read result.
 *
 * @author : Milo
 */
@SuppressWarnings(SuppressWarningConstant.UNUSED)
public class ReadResult implements Serializable {

    private static final long serialVersionUID = 5305104994147833731L;
    private Integer dataCount;
    private Boolean success;
    private String message;
    private CollectExcelDataValid collectExcelDataValid;
    private Integer existCount;


    public CollectExcelDataValid getCollectExcelDataValid() {
        return collectExcelDataValid;
    }

    public void setCollectExcelDataValid(CollectExcelDataValid collectExcelDataValid) {
        this.collectExcelDataValid = collectExcelDataValid;
    }

    public Integer getDataCount() {
        return dataCount;
    }

    public void setDataCount(Integer dataCount) {
        this.dataCount = dataCount;
    }

    public Integer getExistCount() {
        return existCount;
    }

    public void setExistCount(Integer existCount) {
        this.existCount = existCount;
    }

    /**
     * Instantiates a new Read result.
     *
     * @param success the success
     */
    public ReadResult(final Boolean success) {
        this.success = success;
    }


    /**
     * Gets success.
     *
     * @return the success
     */
    public Boolean getSuccess() {
        return this.success;
    }

    /**
     * Sets success.
     *
     * @param success the success
     */
    public void setSuccess(final Boolean success) {
        this.success = success;
    }

    /**
     * Gets message.
     *
     * @return the message
     */
    public String getMessage() {
        return this.message;
    }

    /**
     * Sets message.
     *
     * @param message the message
     */
    public void setMessage(final String message) {
        this.message = message;
    }

    /**
     * Set fail message.
     *
     * @param rowIndex    the row index
     * @param columnIndex the column index
     * @param fileMessage the file message
     */
    public void setFailMessage(final Integer rowIndex, final Integer columnIndex, final String fileMessage) {
        final String messageFormat = "Excel表格:第%s行,第%s列,该数值不符合要求[%s],请校验后重新导入!请检查是否有其他的记录是否含有同类型的错误!";
        this.message = String.format(messageFormat, rowIndex, columnIndex, fileMessage);
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.dataCount, this.success, this.message);
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        final ReadResult readResult = (ReadResult) o;
        return Objects.equals(this.dataCount, readResult.dataCount) && Objects.equals(this.success, readResult.success) && Objects.equals(this.message, readResult.message);
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", ReadResult.class.getSimpleName() + "[", "]")
                .add("dataCount=" + this.dataCount)
                .add("success=" + this.success)
                .add("message='" + this.message + "'")
                .toString();
    }
}
